﻿<style src="../../style/contentTable.css" scoped></style>
<template>
  <div class="containerTable">
    <!--表5蔬菜生产经营实体表T_VegProsecution-->
    <Row class="divSearch">
            <Col span="24" class="col-margin">
            <!--根据需求删除不不要查询条件-->
           填报年份：
            <Select v-model="searchModel.FillInYear" placeholder="全部" :label-in-value="true" @on-change="getPageData()" style="width:200px">
              <Option value="">全部</Option>
                <Option v-for="item in yearList" :value="item.DictValue" :key="item.DictValue">{{ item.DictText }}</Option>
            </Select>
            季节类型：
            <Select v-model="searchModel.TimesCycle" placeholder="全部" :label-in-value="true" @on-change="getResult()" style="width:200px">
                <Option value="">全部</Option>
                <Option v-for="item in seasonList" :value="item.DictValue+'季度'" :key="item.DictValue">{{ item.DictText }}</Option>
            </Select>
            <!-- 报表状态：
            <Select v-model="searchModel.Status" placeholder="全部" :label-in-value="true" @on-change="getResult()" style="width:200px">
                <Option v-for="item in statusList" :value="item.DictValue" :key="item.DictValue">{{ item.DictText }}</Option>
            </Select> -->
            <Button icon="ios-search" type="ghost" @click="getPageData()">查询</Button>            
           <Button icon="ios-download" type="primary" @click="TmpDown()" style="float:right;margin-right:20px">模板下载</Button>        
             <!-- <Button icon="ios-download" type="primary" @click="ExcelDown()" style="float:right;margin-right:20px">数据导出</Button>
            <Upload :on-success="handleSuccess" :action="GetPostUrl()" style="float:right;margin-right:20px" v-show="DataModel.ReportStatus <3">
                <Button type="primary" icon="ios-cloud-upload-outline">数据导入</Button>
            </Upload> -->
            </Col>
        </Row>
        <Row>
            <Col span="24" class="col-margin">
            <Table size="small"  :height="clientHeight" border :context="ctx" :columns="columnsList" :data="datas.rows" no-data-text='暂无数据...'></Table>
            </Col>
        </Row>
        <Row>
            <Col span="24">
            <Page class="page-style" :total="datas.total" placement="top" @on-change="getPageNumber" :page-size="searchModel.PageSize" :page-size-opts='pageSizeOpts' show-sizer @on-page-size-change="getPageSize" show-total show-elevator></Page>
            </Col>
        </Row>
        <Modal v-model="ViewShow" :mask-closable="false" width="1230" :styles="{top: '20px'}">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">主要水果生产情况季度统计表</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <Form ref="DataForm" :model="{list}">
              <table class="ContentTable">
              <thead>
                <tr>                    
                    <th  rowspan="2" >种类</th>
                    <th colspan="2" >在园面积（亩）</th>
                    <th >产量（吨）</th>
                    <th rowspan="2" >季度平均地头批发价（元/公斤）</th>
                    <th rowspan="2" >本季度新增面积（亩）</th>  
                    <th rowspan="2" >备注</th>                  
                </tr>
                <tr>
                    <th >在园水果面积</th>
                    <th >已收获面积</th>
                    <th >已收获产量</th>                    
                </tr>
              </thead>
              <tbody>              
                <tr v-for="(DataModel,index) in list" :key="index" v-if="DataModel.VarietyCode !='sum'">
                    <td v-if="DataModel.ParentCode" style="text-align:right;">{{DataModel.Variety}}</td> 
                    <td v-else style="font-weight:bold;">{{DataModel.Variety}}</td>  
                    
                    <td  >
                            <Form-item :prop="'list.' + index + '.ZyArea'" :rules="{validator: validrule, trigger: 'blur'}">
                            <Input v-model="DataModel.ZyArea" ></Input>                            
                            </Form-item>
                        </td>
                       
                        <td >
                            <Form-item :prop="'list.' + index + '.YshArea'" :rules="{validator: validrule, trigger: 'blur'}">
                            <Input v-model="DataModel.YshArea" ></Input>                            
                            </Form-item>
                        </td>
                        
                        <td >
                            <Form-item :prop="'list.' + index + '.YshYield'" :rules="{validator: validrule, trigger: 'blur'}">
                            <Input v-model="DataModel.YshYield" ></Input>                            
                            </Form-item>
                        </td>                        
                        <td>
                            <Form-item :prop="'list.' + index + '.AvgPrice'" :rules="{validator: validrule, trigger: 'blur'}">
                            <Input v-model="DataModel.AvgPrice" ></Input>                            
                            </Form-item>
                        </td> 
                        
                        <td >
                            <Form-item :prop="'list.' + index + '.AddArea'" :rules="{validator: validrule, trigger: 'blur'}">
                            <Input v-model="DataModel.AddArea" ></Input>                            
                            </Form-item>
                        </td>   
                        <td>
                          <Form-item>
                            <Input v-model="DataModel.Remark" ></Input>                            
                            </Form-item>
                        </td>                 
                </tr>
                <tr>
                  <td style="font-weight:bold;">合计</td>
                  <td>{{tModel.ZyArea}}</td>
                  <td>{{tModel.YshArea}}</td>
                  <td>{{tModel.YshYield}}</td>
                  <td>{{tModel.AvgPrice}}</td>
                  <td>{{tModel.AddArea}}</td>
                  <td>
                      <Form-item>
                        <Input v-model="totalModel.Remark" ></Input>                            
                      </Form-item>
                  </td> 
                </tr>
                </tbody>
                </table>           
        </Form>
        <div style="text-align:right;padding-top:10px">
               <Button type="ghost" v-show="rShow" @click="submit()" >上报</Button>
               <Button type="primary" v-show="pShow" @click="save('DataForm')" style="margin-left: 5px">保存</Button>
               <Button type="ghost" @click="cancel()" style="margin-left: 5px">关闭</Button>
          </div>
            <div slot="footer" style="padding-bottom:50px">
                <Alert style="margin-top:5px;text-align:left" banner type="error">
                    填报时间：4月1日、7月1日、9月30日、12月31日</br>
                    填报说明: 1.全省范围内从乡（镇）起，逐级全面统计，由县级填报经州（市）审核后上报。
                    2.统计面积中不含育苗面积。
                    <span slot="desc">
                    </span>
                </Alert>
            </div>
        </Modal>  
        <Modal v-model="ReasonShow" :mask-closable="false" width="500"> 
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">未通过原因</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <div class="reasonDiv">{{Reason}}</div>
            <p slot="footer"></p>
        </Modal>     
    </div>
</template>
<script>
export default {
  data() {
    const validateData = (rule, value, callback) => {
            var temp = /^[0-9]\d*(\.\d+)?$/;
            if (value != null && value != "") {
                if (temp.test(value) == false) {
                    callback(new Error('必须是数字！'));
                }
                else {
                    callback();
                }
            } else {
                callback();
            }
        };
    return {
      ReasonShow:false,//是否显示未通过原因Modal
      Reason:'',//未通过原因
      rShow:false,//是否显示上报按钮
      pShow:false,//是否显示保存按钮
      list: [],
      templist:[],
      totalModel:{
        Variety: "",
        ZyArea: "",
        YshArea: "",
        YshYield: "",
        AvgPrice: "",
        AddArea: "",
        Remark:""
      },
      ViewShow: false, //编辑框弹出状态
      reportId: "",
      validrule:validateData,
      ruleValidate: {
        //验证模型
        ReportId: [
          { required: true, message: "填报基_报表编号不能为空", trigger: "blur" }
        ],
        Variety: [{ required: true, message: "种类不能为空", trigger: "blur" }],
        ZyArea: [{ required: true, message: "在园水果面积(亩）不能为空", trigger: "blur" }],
        YshArea: [{ required: true, message: "已收获面积（亩）不能为空", trigger: "blur" }],
        YshYield: [
          { required: true, message: "已收获产量（吨）不能为空", trigger: "blur" }
        ],
        AvgPrice: [
          { required: true, message: "季度平均地头批发价（元/公斤）不能为空", trigger: "blur" }
        ],
        AddArea: [
          { required: true, message: "本季度新增面积（亩）不能为空", trigger: "blur" }
        ]
      },
      yearList: this.GetGroupDict("ReportYear"), //周期
      seasonList: this.GetGroupDict("QuarterCycleValue"), //季节类型列表
      statusList: this.GetGroupDict("ReportStatus"), //报表状态类型列表
      dataModel: {
        //编辑模型
        Id: 0,
        ReportId: "",
        Variety: "",
        ZyArea: "",
        YshArea: "",
        YshYield: "",
        AvgPrice: "",
        AddArea: ""
      },
      clientHeight: window.innerHeight - 260, //表格默认高度
      //查询模型：根据需求删除不不要查询条件
      searchModel: {
        Id: "",
        ReportId: "",
        Variety: "",
        ZyArea: "",
        YshArea: "",
        YshYield: "",
        AvgPrice: "",
        AddArea: "",
        ReportCode: "FruProSeason",
        FillInYear:'',
        TimesCycle: "",
        AreaCode: "",
        PageNumber: 1,
        PageSize: 20
      },
      pageSizeOpts: [20, 40, 50], //默认分页最大设置
      datas: {}, //table数据对象
      dataIds: [],
      ctx: this, //table数据上下文
      columnsList: [
        //表头对象
        // { type: 'selection', width: 60, align: 'center' },//多选设置
        { title: "报表名称", key: "ReportName" },
        { title: "所属行政区划", key: "AreaCodeName",width: 150 },
        //{ title: "填报年度", key: "FillInYear", width: 150 },
        //{ title: "填报周期", key: "TimesCycle" , width: 150  },
        {
          title: "报表状态",
          key: "StatusName",
          width: 150,
          render: (h, params) => {
            switch (params.row.Status * 1) {
              case 0:
                return h(
                  "span",
                  { style: { color: "#ed3f14" } },
                  params.row.StatusName
                );
              case 1:
                return h(
                  "span",
                  { style: { color: "#ff9900" } },
                  params.row.StatusName
                );
              case 2:
                return h(
                  "span",
                  { style: { color: "#993300" } },
                  params.row.StatusName
                );
              case 3:
                return h(
                  "span",
                  { style: { color: "#2d8cf0" } },
                  params.row.StatusName
                );
              case 4:
                return h(
                  "span",
                  { style: { color: "#19be6b" } },
                  params.row.StatusName
                );
              case 5:
                return h(
                  "span",
                  { style: { color: "#80848f" } },
                  params.row.StatusName
                );
              default:
                return h(
                  "span",
                  { style: { color: "#ff9900" } },
                  params.row.StatusName
                );
            }
          }
        },
         /* { title: "未通过原因", key: "Opinion", render: (h, params) =>{
           switch (params.row.Status * 1){
             case 0: return 
             default:
             return h(
               "span" ,                
                  { style: { display: 'none' } },
                   params.row.Opinion                
                );
           }
         }}, */
        { title: "填报时间", key: "StrUpdateTime", width: 180 },
        {
          title: "操作",
          key: "Id",
          width: 320,
          align: "center",
          render: (h, params) => {
            var reasonStyle = {display:'none'};
            if((params.row.Status*1)== 0)
            reasonStyle = {};
            return h("div", [
              h(
                "Upload",
                {
                  props: {
                    //导入成功后响应窗口
                    onSuccess: (response) => {
                      this.handleSuccess(response);
                    },
                    action: this.GetPostUrl(params.row.Id),
                    size: "small"
                  },
                  style: {
                    float: "left"
                  }
                },
                [
                  h(
                    "Button",
                    {
                      class: { searchButton: true },
                      props: {
                        type: "ghost",
                        size: "small",
                        icon: "ios-cloud-upload-outline",
                        disabled:
                          params.row.Status == 3 || params.row.Status == 4
                      },
                      style: {
                        marginRight: "5px"
                      }
                    },
                    "导入"
                  )
                ]
              ),
              h(
                "Button",
                {
                  class: {
                    ieditColor: true
                  },
                  props: {
                    size: "small",
                    type: "ghost",
                    icon: "ios-compose"
                  },
                  style: {
                    marginRight: "5px"
                  },                  
                  on: {
                    click: () => {
                      if(params.row.Status == 2){
                         this.rShow = true; 
                         this.pShow = true;
                      }                         
                      else if(params.row.Status <= 1) {
                         this.pShow = true;
                      }                                       
                      this.editInfo(params.row.Id, params.row.ReportCode);
                    }
                  }
                },(params.row.Status <= 2)?"填报":"查看"),                
              h(
                "Button",
                {
                  class: { ieditColor: true },
                  props: {
                    type: "ghost",
                    size: "small",
                    icon: "ios-compose"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  attrs: {
                    disabled: params.row.Status < 2 ? true : false
                  },
                  on: {
                    click: () => {
                      this.ExcelDown(params.row);
                    }
                  }
                },
                "导出"
              ),
              h(
                 "Button",
                {
                  class: {
                   // ieditColor: true
                  },
                  props: {
                    size: "small",
                    type: "error",
                    //icon: "ios-compose"
                  },
                  style: reasonStyle,            
                  on: {
                    click: () => {
                      this.Reason = params.row.Opinion;
                      this.ReasonShow = true;
                    }                  
                  }
                },"未通过原因"),
            ]);
          }
        }
      ]
    };
  },
  mounted() {
    //table高度计算方法
    const that = this;
    window.onresize = () => {
      return (() => {
        that.clientHeight = window.innerHeight - 260;
      })();
    };
  },
  methods: {
    //获取当前页码
    getPageNumber(pageIndex) {
      this.searchModel.PageNumber = pageIndex;
      this.getPageData();
    },
    //获取当前分页大小
    getPageSize(pageSize) {
      this.searchModel.PageSize = pageSize;
      this.getPageData();
    },
    //获取this.datas: {},//table数据对象
    getPageData() {
      var self = this;
      var user = this.GetlocaStorage("fruuserinfo");
      this.searchModel.AreaCode = user.AreaCode;
      self.$http
        .post("Report/PostPageList", this.searchModel)
        .then(function(res) {
          if (res.data.status === 1) {
            self.datas = res.data;
          } else {
            self.$Modal.error({ title: "提示信息", content: res.data.message });
          }
        });
    },
    //编辑获取对象传入id
    editInfo(id, reportCode) {
      //编辑
      this.reportId = id;
      var self = this;
      this.$http
        .get("Report", { params: { id: id, reportCode: reportCode } })
        .then(function(res) {
          if (res.data.list.status == 1) {
            self.list = res.data.list.model;
            /* for(let i = 0; i< self.list.length-1;i++){
              let model = new Object();
              model = self.list[i];
              model.hasChild = false;
              for(let j = 0; j< self.list.length-1;j++){
                if(self.list[j].ParentCode == self.list[i].VarietyCode){
                  model.hasChild = true;
                  break;
                }
              }
              self.list[i] = model;
            } */
            /* let temp = [];
            for(var i = 0;i<self.list.length;i++){
              var item = self.list[i];
              if(item.VarietyCode != 'sum'){
                temp.push(item);
              }
              else{
                self.totalModel = item;
              }
            }           
            self.templist = temp; */
            self.ViewShow = true; //打开modal
          } else {
            self.$Modal.error({ title: "提示信息", content: "编辑数据加载失败!!!" });
          }
        });
    },
    //删除对象
    delInfo(id) {
      var self = this;
      self.$Modal.confirm({
        title: "提示信息",
        content: "<p>数据删除后不可恢复，确定要删除？</p>",
        onOk: () => {
          this.$http
            .delete("FruProSeason", { params: { id: id } })
            .then(function(res) {
              if (res.data.status == 1) {
                self.$Notice.success({ title: "删除成功！", desc: false });
                self.getPageData();
              } else {
                self.$Modal.error({ title: "提示信息", content: "数据删除失败!!!" });
              }
            });
        }
      });
    },
    //上报方法
    submit() {
      var self = this;
      if(this.checkData()){
      self.$Modal.confirm({
        title: "提示信息",
        content: "<p>是否确认上报？</p>",
        onOk: () => {
          let obj = new Object();
          obj.Id = this.reportId;
          obj.reportType = "3";
          obj.strMsg = "";
          this.$http.post("Report/PostUpStatus", obj).then(function(res) {
            if (res.data.status == 1) {
              self.ViewShow = false;
              self.getPageData();
              self.$Notice.success({ title: "上报成功！", desc: false });
            } else {
              self.$Modal.warning({
                title: "提示信息",
                content: "上报失败,请与管理员联系!"
              });
            }
          });
        }
      });}
    },
    //保存方法
    save(modelname) {
      var self = this;
      //this.Dsum();
      let len = this.list.length;
      this.list[len-1].Remark = this.totalModel.Remark;           
      this.$refs[modelname].validate(valid => {
        if (valid) {
          this.$http.put("FruProSeason", this.list).then(function(res) {
            if (res.data.status == 1) {
              self.getPageData(); //读取分页数据
              //self.restModel(modelname); //重置model
              //self.modalHide(); //关闭modal
              self.rShow = true;
              self.$Notice.success({ title: "保存成功！", desc: false });
            } else {
              self.$Modal.warning({
                title: "提示信息",
                content: "保存失败,请与管理员联系!"
              });
            }
          });
        }
        else{
          self.$Modal.error({title:"提示信息",content:"填入的必须是数字！"})
        }
      });
    },
    TmpDown: function() {
      //模板下载
      window.open(
        this.$http.defaults.baseURL +
          "Report/GetTemplateData?ReportCode=" +
          this.searchModel.ReportCode
      );
    },
    //导入
    GetPostUrl(ReportId) {
      var url =
        this.$http.defaults.baseURL +
        "FruProSeason/PostImportData?ReportId=" +
        ReportId;
      return url;
    },
    handleSuccess(response) {      
      //导入成功反馈事件
      this.getPageData();
      if(response.status == -1){
        this.$Modal.warning({
                title: "提示信息",
                content: response.message
        });
      }else{
        this.$Notice.success({
        title: "数据导入成功！",
        desc: false
      });
      }
      
    },
    //导出
    ExcelDown: function(model) {
      var self = this;
      window.open(
        this.$http.defaults.baseURL +
          "FruProSeason/GetExcelData?ReportId=" +model.Id+"&&FillInYear=" + model.FillInYear+"&&TimesCycle="+model.TimesCycle+"&&AreaName="+model.AreaCodeName         
      );
    },
    //合计
    Dsum(){
      var self = this;
      let model = new Object();
      model.ZyArea = 0;
      model.YshArea = 0;
      model.YshYield = 0;
      model.AddArea = 0;           
      for(let i=0; i<self.list.length; i++){
        let item = self.list[i];        
        if(item.VarietyCode !='sum'){
          if(!item.ParentCode){
            if(item.ZyArea !=null&&item.ZyArea!='')
              model.ZyArea += Number(item.ZyArea);
           if(item.YshArea !=null&&item.YshArea!='')
              model.YshArea += Number(item.YshArea);
           if(item.YshYield !=null&&item.YshYield!='')
              model.YshYield += Number(item.YshYield);
           if(item.AddArea !=null&&item.AddArea!='')
              model.AddArea += Number(item.AddArea);  
          }                                  
        }
        else{
          self.list[i].ZyArea = model.ZyArea.toFixed(1);
          self.list[i].YshArea = model.YshArea.toFixed(1);
          self.list[i].YshYield = model.YshYield.toFixed(1);
          self.list[i].AddArea = model.AddArea.toFixed(1);
        }
      } 
          model.ZyArea = model.ZyArea.toFixed(1);
          model.YshArea = model.YshArea.toFixed(1);
          model.YshYield = model.YshYield.toFixed(1);
          model.AddArea = model.AddArea.toFixed(1);        
      return model;      
    }, 
    //检验有其中项的数据项。（合计栏已经被computed属性改变过一定计算正确，要是在审核阶段合计栏的数据与县级看到的不同则说明县级没重新保存数据） 
    checkData(){
      let templist = this.list;     
     /* let sumObj = templist[templist.length-1];//合计栏数据
     let totalModel = new Object();
     totalModel.ZyArea = 0;
     totalModel.YshArea = 0;
     totalModel.YshYield = 0;
     totalModel.AddArea = 0;   */
     for(let i = 0;i < templist.length;i++){
       let item  = templist[i];
       let parentModel = new Object();
       parentModel.ZyArea = 0;
       parentModel.YshArea = 0;
       parentModel.YshYield = 0;
       parentModel.AddArea = 0; 
       parentModel.hasChild = false; 
       for(let j = 0;j < templist.length;j++){
        let sonItem = templist[j];
        if(sonItem.ParentCode == item.VarietyCode){
          parentModel.hasChild = true;
          if(sonItem.ZyArea){
            parentModel.ZyArea += sonItem.ZyArea;
          }
          if(sonItem.YshArea){
            parentModel.YshArea += sonItem.YshArea;
          }
          if(sonItem.YshYield){
            parentModel.YshYield += sonItem.YshYield;
          }
          if(sonItem.AddArea){
            parentModel.AddArea += sonItem.AddArea;
          }
        }
       }
       if(parentModel.hasChild){  
       if(item.ZyArea && parentModel.ZyArea.toFixed(1) > item.ZyArea.toFixed(1)){  
        this.toAlertCheckResult(item.Variety+'的在园面积不能小于其子项之和！');
        return false;        
       }
       if(item.YshArea && parentModel.YshArea.toFixed(1) > item.YshArea.toFixed(1)){
         this.toAlertCheckResult(item.Variety+'的已收获面积不能小于其子项之和！');
         return false;
       }
       if(item.YshYield && parentModel.YshYield.toFixed(1) > item.YshYield.toFixed(1)){ 
        this.toAlertCheckResult(item.Variety+'的已收获产量不能小于其子项之和！');
        return false;
       }
       if(item.AddArea && parentModel.AddArea.toFixed(1) > item.AddArea.toFixed(1)){
        this.toAlertCheckResult(item.Variety+'的季度新增面积不能小于其子项之和！');
        return false;
          }   
       }    
       /* if(item.VarietyCode !='sum'&& !item.ParentCode){        
         if(item.ZyArea){
           totalModel.ZyArea += item.ZyArea;
         }
         if(item.YshArea){
           totalModel.YshArea += item.YshArea;
         }
         if(item.YshYield){
           totalModel.YshYield += item.YshYield;
         }
         if(item.AddArea){
           totalModel.AddArea += item.AddArea;
         }
       } */
     }
     /* if(sumObj.ZyArea && totalModel.ZyArea != sumObj.ZyArea){       
       isOk = false;
       return '合计栏的在园面积计算错误！';
     }
     if(sumObj.YshArea && totalModel.YshArea != sumObj.YshArea){
       isOk = false;
       return '合计栏的已收获面积计算错误！';
     }
     if(sumObj.YshYield && totalModel.YshYield != sumObj.YshYield){
       isOk = false;
       return '合计栏的已收获产量计算错误！';
     }
     if(sumObj.AddArea && totalModel.AddArea != sumObj.AddArea){
       isOk = false;
       return '合计栏的季度新增面积计算错误！';
     } */
     return true;
    },
    toAlertCheckResult(message){   
      this.$Modal.warning({
        title:'提示信息',
        content:message
      });
    },     
    //编辑框打开
    modalShow() {
      this.ViewShow = true;
    },
    //编辑框关闭
    modalHide() {
      this.ViewShow = false;
    },
    //取消方法
    cancel() {
      this.ViewShow = false;
    },
    //重置model
    restModel(modelname) {
      this.$refs[modelname].resetFields(); //重置model
    },    
    CurrentSeason(){
      var self = this;
      let currentMonth = new Date().getMonth()+1;      
      if(currentMonth >= 2 &&currentMonth <= 5){
        self.searchModel.TimesCycle = "1季度";
      }
      else if(currentMonth >= 6&&currentMonth <= 8){
        self.searchModel.TimesCycle = "2季度";
      }
      else if(currentMonth >= 9&&currentMonth <= 11){
        self.searchModel.TimesCycle = "3季度";
      }
      else{
        self.searchModel.TimesCycle = "4季度";
      }
    },
    Psum(index,VarietyCode){           
            let model = new Object();
            model.ZyArea = 0;
            model.YshArea = 0;
            model.YshYield = 0;
            model.AddArea = 0;              
            for(let p = 0;p < this.list.length-1;p++){
              let item = this.list[p];
              if(item.ParentCode == VarietyCode){                
                console.log(item.ZyArea)
                if(item.ZyArea !=null&&item.ZyArea!='')
                  model.ZyArea += Number(item.ZyArea);
              if(item.YshArea !=null&&item.YshArea!='')
                  model.YshArea += Number(item.YshArea);
              if(item.YshYield !=null&&item.YshYield!='')
                  model.YshYield += Number(item.YshYield);
              if(item.AddArea !=null&&item.AddArea!='')
                  model.AddArea += Number(item.AddArea);  
              }
            }                       
          this.list[index] = model;                                
          return model;
    },
            currentYear(){
                let year = new Date().getFullYear();
                let month = new Date().getMonth();                
                if(month>1){
                    this.searchModel.FillInYear = year.toString();
                }
                else{
                    this.searchModel.FillInYear = (year - 1).toString();
                }                
            }
  },
  computed:{    
    tModel:{
      get:function(){
        return this.Dsum();
      }      
    },
    clist:{
        get:function(){          
          return this.Psum();
        }
      }
  },
  //创建Vue页面方法
  created: function() {
    //创业Vue前调用获取this.datas: {},//table数据对象
    this.CurrentSeason();
    this.currentYear();
    this.getPageData();
  },
  watch: {
    //需要监听的在此处新增监听对象
    /* list:{
      handler(curVal,oldVal){
        console.log("8830")
        let templist = curVal;
        for(let i=0;i < curVal.length-1;i++){
          let model = curVal[i];
            model.ZyArea = 0;
            model.YshArea = 0;
            model.YshYield = 0;
            model.AddArea = 0;
            let haschild = false;
          for(let j = 0; j < curVal.length-1;j++){
            let item = curVal[j];
            if(item.ParentCode == model.VarietyCode){
              haschild = true;
              if(item.ZyArea !=null&&item.ZyArea!='')
                  model.ZyArea += Number(item.ZyArea);
              if(item.YshArea !=null&&item.YshArea!='')
                  model.YshArea += Number(item.YshArea);
              if(item.YshYield !=null&&item.YshYield!='')
                  model.YshYield += Number(item.YshYield);
              if(item.AddArea !=null&&item.AddArea!='')
                  model.AddArea += Number(item.AddArea);  
              }
            }
            if(haschild)
            templist[i] = model;
          }
          list = templist;
        },
        deep:true
      } */
      
  }
    
  
};
</script>
